<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.netscenery.yang.model.Deviation"%>
<%@page import="offer.SessionObj"%>
<%@page import="operate.OperateType"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Deviation deviation = new Deviation();
//获取结点对象
Object itemNode = request.getAttribute("itemNode");
Object opType   = request.getAttribute("opType"); //获取操作对象
if( null != itemNode){
	deviation = (Deviation)itemNode;
}
//Session ModuleStatus control
SessionObj sessionObj = (SessionObj)request.getSession().getAttribute("sessionObj");
String control_disabled = "";
if(!sessionObj.getModuleStatus().toString().equalsIgnoreCase("EDITING")){
 	control_disabled ="disabled='disabled'";
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Deviation</title>
    
	 <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/items.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/subItems.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/deviation.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/index.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/Tab.css" />
    <script type="text/javascript"  src="<%=basePath%>jstree-v.pre1.0/_lib/jquery.js"></script>
    <script type="text/javascript"  src="jstree-v.pre1.0/jquery.jstree.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/coverLayer.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/StringUtil.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/MjTab.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/deviation.js"></script>
</head>

<body class="body">
<script type="text/javascript">
 function bodyLoad(){
   <% if( (null != itemNode) 
        &&  (!opType.toString().equalsIgnoreCase(OperateType.LOAD))){ %>
  <%   		 if(opType.toString().equalsIgnoreCase(OperateType.ADD)
	            || opType.toString().toString().equalsIgnoreCase(OperateType.MODIFY_INCLUDE_NAME)){ %>
	   		 	 //新增节点时，重新加载数
	   		 	 parent.reloadTreeWithNode("root");
  <%   	} %>
			 $("#opNoticeSpan").html("操作成功！");
   		 	 setTimeout(function(){$("#opNoticeSpan").html("")},3000);
   <% }%>  
   }

     var currNodeId ="";
	 $(document).ready(function(){
 		 bodyLoad();
 		 var currNodeId_str = document.getElementById("currNodeId").value.split("/");
 		 currNodeId  = "Note\\"+currNodeId_str[1];
 		 for(i = 2 ; i < currNodeId_str.length ; i++){
 		 	//alert(currNodeId_str[i]);
 		 	currNodeId +="\\"+currNodeId_str[i]
 		 }
	     $("#B_Search").click(function () {
	         var key_text = $("#search_key").val();
			 $("#popTreeContent").jstree("search", key_text);
	     });
	     $("#search_key").keypress(function(e){
   			var curKey = e.which;
   			if(curKey == 13)
   			{
       			var key_text = $("#search_key").val();
       			$("#popTreeContent").jstree("search", key_text);
   			}
   		});
		
	 });
	 function fromSubmit(){
	 	if($("#_name").val().trim().length == 0){
	        $("#_name").css("border-color","red");
	        alert("name 不能为空！");
	        return;
	     }
	     
         document.getElementById("deviatonForm").submit();
	 }
</script>
<!-- ********************************** 页面布局最外层 Body Container *************************************** -->
<div id="Body_Container" class="" style="margin:0px auto;padding:0px;">
	<!-- *****************************Title Bar Container Begin****************************************** -->
	<div class="navTitle" style="display:none;">
   		<ul id="navTabTitle">
     		<li id="mainContent_ico" onclick="showThis('mainContent')">Main Content</li>
   		</ul>
        <div style="clear:both;"></div>
    </div><!-- Title Bar Container End -->
    <!-- *****************************Main Container Begin****************************************** -->
    <div id="mainContent_tab" class="" style="padding:0px;margin:0px;"> 
	   <form id="deviatonForm" method="post" action="<%=basePath %>DeviationOpreateServlet" class="IndexFormStyle" >
	   <input type="hidden"  id="nodeId" name="nodeId" value="<%=request.getAttribute("nodeId") %>"  />
	   <input type="hidden"  id="currNodeId" name="currNodeId" value="<%=deviation.getEnv().getCurNode().getPath() %>"  />
	   <div id="TableContent" class="typeSubContent" >
	      <div class="itemTitle">
	          The Deviation [<%=deviation.getClass().getSimpleName() %>] information 
	      </div>
	      &nbsp;Deviation name:&nbsp;<input class="inputText" id="_name" name="_name" value="<%=deviation.getName() %>" readonly="readonly" />
	      <img class='buttonBcImg' style='cursor:pointer;' width='22' src='./images/edit.jpg' onclick='javascript:getModuleList()' />
	      <br/><br/>
	      <div class="itemDiv">
		   	  <span class="textSpan">&nbsp;Description:</span><br/>
		      <textarea class="textArea"  id="description" name="description"><%=deviation.getDescription()==null?"":deviation.getDescription() %></textarea>
		   </div>
		   <div class="itemDiv">
		   	  <span class="textSpan">&nbsp;Reference:</span><br/>
		      <textarea class="textArea"  id="reference" name="reference"><%=deviation.getReference()==null?"":deviation.getReference() %></textarea>
		   </div>
		   <div class="inContent" >
		   		&nbsp;Create Deviate: 
		   		<select id="Deviate_Type" name = "Deviate_Type" >
		      		<option value="not-supported" selected="selected">UNSUPPORTED</option>
		      		<option value="add">ADD</option>
		      		<option value="delete">DELETE</option>
		      		<option value="replace">REPLACE</option>
		      	</select>
		   		<input type="button" id="B_DeviateAdd" name="B_DeviateAdd" onclick="CreateDeviate()" <%=control_disabled %> value="Add Deviate" /><br/>
		   		<div id="deviatesContent" class="itemContent">
		   		
		   		</div>
		   </div>
	   </div>
	   <div id="submitContent" class="submitContent">
	     <span id="opNoticeSpan" style="color:red;" ></span>
	     <span class="textSpan">&nbsp;</span>
	     <input type="button" onclick="fromSubmit()" value="Apply" <%=control_disabled %>  />
	   </div>
	   </form>
   </div><!-- Main Container End -->
</div><!-- Body Container End -->
 
 
  <div id="coverDiv" class="coverDiv"></div> <!-- 覆盖层，要放在所有弹出层之前 -->
  <div id="chooseModuleContainer" class="addContenter" style="display:none;">
  	<div id="addItem_title">
        <div id="createMimMap_title" style="float:left; font-weight:bold;">Choose Module</div>
        <div style="float:right;">
            <a href="javascript:void(0);" id="chooseModule_close" title="close">close</a>
        </div>
        <div style="clear:both" ></div>
    </div>
    <div id ="chooseModule_container">
    	
    </div>
  </div>
  <div id="addTreeContent" class="addTreeContenter">
    <div id="popTreeContent"  style="WIDTH: 300px; HEIGHT: 370px; OVERFLOW: auto; scrollbar-face-color: #DBEBFE; scrollbar-shadow-color: #B8D6FA; scrollbar-highlight-color: #FFFFFF; scrollbar-3dlight-color: #DBEBFE; scrollbar-darkshadow-color:#458CE4; scrollbar-track-color: #FFFFFF; scrollbar-arrow-color: #458CE4;">
    </div>
    <div id="searchBar" style=" background:#425DA5;padding:1px;">
	   <input type="text" id="search_key" name="search_key"  />
	   <input type="button" value="Search" id="B_Search" />
	   <!-- <input type="button" value="C" id="B_Clean" /> -->
	   <input type="button" value="Close" id="B_Close" />
    </div>
  </div>
  </body>
</html>
